<?php
class Mapper_DienstCategorie extends DBTable{

	public function __construct(Database $db = null){
		parent::__construct("dienst_categorie", $db);
	}
	
	public function get($dienst_categorie_id){
		$query = "
SELECT
	dienst_categorie.*,
	IFNULL((
		SELECT
			true
		FROM
			dienst
		WHERE
			dienst.dienst_categorie_id = dienst_categorie.dienst_categorie_id
		LIMIT 1
	), false) AS IsInUse
FROM dienst_categorie
WHERE
	dienst_categorie_id = :dienst_categorie_id";
		
		$stmt = $this->prepare($query);
		$stmt->bindParam(":dienst_categorie_id", $dienst_categorie_id);
		
		return $stmt->fetchObjectOnce("DienstCategorie");
	}

	public function getAll(){
		$query = "
SELECT
	dienst_categorie.*,
	IFNULL((
		SELECT
			true
		FROM
			dienst
		WHERE
				dienst.dienst_categorie_id = dienst_categorie.dienst_categorie_id
		LIMIT 1
	), false) AS IsInUse
FROM dienst_categorie";
		
		return $this->prepare($query)->fetchObjectAll("DienstCategorie");
		
	}
	
	
	
}